<?php
/*
 * @Author: 李明
 * @Date: 2022-01-13 17:40:23
 * @LastEditTime: 2022-01-13 17:54:40
 * @LastEditors: 李明
 * @Description:
 * @FilePath: /CRM2.0-PHP/app/Http/Resources/OrderInterest/OrderInterestRecord.php
 * @山东壹零贰肆信息科技有限公司
 */

namespace App\Http\Resources\OrderInterest;

use Illuminate\Http\Resources\Json\JsonResource;

class OrderInterestRecord extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        $data['contract_no'] = $this->order->contract_no; // 合同号
        $data['order_money'] = $this->order->order_money; // 订单金额
        $data['user_name'] = $this->order->user->name; // 客户名称
        $data['worker_name'] = $this->worker->name ?? ''; // 操作人
        $data['interest'] = $this->interest_record->interest; // 应付收益
        $data['money'] = $this->interest_record->money; // 应付本金
        $data['interest_money'] = $this->interest_record->interest_money; // 实际付款
        $data['date'] = date('Y-m-d', strtotime($this->interest_record->date)); // 应付款时间
        $data['create_time'] = date('Y-m-d H:i:s', strtotime($this->create_time)); // 操作时间
        $data['remark'] = $this->remark; // 备注
        return $data;
    }
}
